package demo3;

abstract class Animal {
    public String name;
    public int age;

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }
}

interface IFly {
    void fly();
}

interface IRun {
    void Run();
}

interface ISwim {
    void Swim();
}

class Dog extends Animal implements IRun {
    public Dog(String name, int age){
        super(name, age);
    }
    @Override
    public void Run() {
        System.out.println(this.name + "正在跑！");
    }
}

class Frog extends Animal implements ISwim,IRun {
    public Frog(String name, int age) {
        super(name, age);
    }

    @Override
    public void Swim() {
        System.out.println(this.name + "蛙泳");
    }

    @Override
    public void Run() {
        System.out.println(this.name + "跳跳");
    }
}

class Duck extends Animal implements ISwim,IRun,IFly {
    public Duck(String name, int age) {
        super(name, age);
    }

    @Override
    public void fly() {
        System.out.println(this.name + "在飞");
    }

    @Override
    public void Run() {
        System.out.println(this.name + "双脚跑");
    }

    @Override
    public void Swim() {
        System.out.println(this.name + "鸭泳");
    }
}

public class Test {
    public static void running(IRun iRun) {
        iRun.Run();
    }

    public static void flying(IFly iFly) {
        iFly.fly();
    }

    public static void main(String[] args) {
        running(new Dog("二狗",11));
        flying(new Duck("唐老鸭",10));
    }
}
